<?php 
// Init owncloud
require_once(OC_App::getAppPath('company') . "/lib/company.php");
$lang = PFactory::getLanguage();
$lang->load("com_jobs", JPATH_SITE, "zh-CN");
OCP\JSON::callCheck();
if(!OC_User::isLoggedIn()) {
   echo '您需要先登录';
   exit;
} else {
   if (PFactory::isJobseekerUser()) {
      echo "您无权访问该资源！";
      exit;
   }
}
$model = new PCompanyModelCompany();
$industryList=$model->getCompanyIndustryList();
$current_id_industry=JRequest::getInt('id_industry',0);
?>
<div class="dialogp_content">
      <div class="postionlisttable medium" style="max-height:320px;height:auto;border-top:none;margin-top:0px;">
      	<table width="100%" cellpadding="0" cellspacing="0" border="0">
      	   <tbody>
      		<tr>
            <?php 
            $n=count($industryList);
            for ($i=0; $i < $n; $i++) {
               $selected= false;
               $industry= $industryList[$i];
               if ($i != 0 && ($i%3) == 0) {
                  echo '</tr><tr>';
               }  
               if($current_id_industry==$industry['id']) $selected= true;          
            ?>

            <td width="33%"><a href="javascript:;" class="<?=($selected ? 'cur_a':'')?>" data-id="<?=$industry['id'];?>" data-industry="<?=JText::_($industry['industry'])?>"><?=JText::_($industry['industry'])?></a>

            </td>
            <?php 
            }
            
            $filledNum = 3 - ($n%3);
            if ($filledNum < 3) {
               for ($i=0; $i < $filledNum; $i++) {
                  echo '<td width="33%"></td>';
               }
            }
            ?>
         </tr>
      	   </tbody>
      	</table>
      </div>
</div>

<script type="text/javascript">
   $('.dialogp_content table').on('click','a',function(){
      var target = $(this);
      $('#industry_name').val(target.data('industry'));
      $('#id_industry').val(target.data('id'));
      $("#selectindustry_dialog").modal('hide');
   })
   $('#selectindustry_dialog').on('click','.removeselected',function(){
      $(".dialogp_content table a.cur_a").removeClass("cur_a");
      $("#id_industry").val('');
      $("#industry_name").val('');
   })
</script>